package sii.fb.emotion.bean;

import java.sql.Time;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;

public class Post {
	Long id;
	String message;
	Date update;
	Time time;
	float[] emotion;
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Post other = (Post) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return "Post [id=" + id + ", message=" + message + ", update=" + update
				+ ", time=" + time + ", emotion=" + Arrays.toString(emotion)
				+ "]";
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public Date getUpdate() {
		return update;
	}
	public void setUpdate(String update) {
		Date date = null;
		Time ora = null;
		update = update.replace("T", " ");
		try {
			date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(update);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		this.setTime(Time.valueOf(new SimpleDateFormat("HH:mm:ss").format(date)));
		this.update = date;
	}
	public Time getTime() {
		return time;
	}
	public void setTime(Time time) {
		this.time = time;
	}
	public float[] getEmotion() {
		return emotion;
	}
	public void setEmotion(float[] emotion) {
		this.emotion = emotion;
	}

	

}
